﻿using System;
using System.Windows.Forms;

namespace ViewCam
{
    public partial class TimeForm : Form
    {
        public TimeForm()
        {
            InitializeComponent();
        }

        #region Properties
        /// <summary>
        /// Gets or sets the cam form.
        /// </summary>
        /// <value>
        /// The cam form.
        /// </value>
        public CameraForm camForm { get; set; }
        /// <summary>
        /// Gets or sets the cam IP form.
        /// </summary>
        /// <value>
        /// The cam IP form.
        /// </value>
        public CameraIPForm camIPForm { get; set; }
        #endregion

        #region Methods/Events
        /// <summary>
        /// Handles the Click event of the btnNote control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnNote_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Schedule only within a day.", "View Cam Note");
        }

        /// <summary>
        /// Handles the Click event of the btnClose control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnClose_Click(object sender, EventArgs e)
        {
            if (dtmStart.Value != dtmEnd.Value)
            {
                if (dtmStart.Value < dtmEnd.Value)
                {
                    if (dtmStart.Value > DateTime.Now)
                    {
                        if (camForm != null & camIPForm == null)
                        {
                            camForm.startTime = dtmStart.Value;
                            camForm.endTime = dtmEnd.Value;
                        }
                        else if (camForm == null & camIPForm != null)
                        {
                            camIPForm.startTime = dtmStart.Value;
                            camIPForm.endTime = dtmEnd.Value;
                        }
                    }
                }
            }

            this.Close();
        }
        #endregion
    }
}
